package com.airline.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

import com.airline.beans.Journey;
import com.airline.connection.AirlineSystemServiceProxy;
import com.airline.form.DeleteJourneyIDForm;

public class DeleteJourneyIDAction extends DispatchAction{
	AirlineSystemServiceProxy proxy = new AirlineSystemServiceProxy();
	
	public ActionForward deleteId(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		
		String journeyID = request.getParameter("journeyID");
		
		
		
		Journey jour = proxy.getJourney(journeyID);

		if (null == jour) {

		  ((DeleteJourneyIDForm)	(form)).setError("No reservation with the ID " + journeyID + " exists");
			return mapping.findForward("failure");
		}

		

		boolean res = proxy.cancelJourney(journeyID);
		
		return mapping.findForward("success");
		
	}


}
